package com.weareint.examples.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.weareint.examples.dto.CompanyDTO;
import com.weareint.common.entity.AbstractEntity;
import com.weareint.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 *
 *
 * <pre>
 *     客户与供应商
 * </pre>
 *
 * @author Auto Generator
 * @date 2021-07-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("company")
@ApiModel(value = "客户与供应商", description = "客户与供应商")
public class Company extends AbstractEntity<CompanyDTO> {

    @ApiModelProperty(value = "公司名称")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "公司编码")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "状态: 0正常，1禁用")
    @TableField("state")
    private Integer state;

    @ApiModelProperty(value = "联系人")
    @TableField("contacts")
    private String contacts;

    @ApiModelProperty(value = "手机号")
    @TableField("mobile")
    private String mobile;

    @ApiModelProperty(value = "备注")
    @TableField("remark")
    private String remark;

    @ApiModelProperty(value = "类型：0表示客户，1表示供应商")
    @TableField("type")
    private Integer type;

    @ApiModelProperty(value = "")
    @TableField("material_id")
    private Long materialId;

    @ApiModelProperty(value = "")
    @TableField("product_id")
    private Long productId;



    public static final String ID ="id";

    public static final String CREATE_TIME ="create_time";

    public static final String UPDATE_TIME ="update_time";

    public static final String CREATOR ="creator";

    public static final String UPDATER ="updater";

    public static final String NAME ="name";

    public static final String CODE ="code";

    public static final String STATE ="state";

    public static final String CONTACTS ="contacts";

    public static final String MOBILE ="mobile";

    public static final String REMARK ="remark";

    public static final String TYPE ="type";

    public static final String MATERIAL_ID ="material_id";

    public static final String PRODUCT_ID ="product_id";


    public static final String[] COLUMNS =
            new String[] {
                    ID,
                    CREATE_TIME,
                    UPDATE_TIME,
                    CREATOR,
                    UPDATER,
                    NAME,
                    CODE,
                    STATE,
                    CONTACTS,
                    MOBILE,
                    REMARK,
                    TYPE,
                    MATERIAL_ID,
                    PRODUCT_ID
            };

    /**
     *
     *
     * <pre>
     *     创建对应的DTO
     * </pre>
     * @return {@link CompanyDTO}
     */
    @Override
    public CompanyDTO toDTO() {
        CompanyDTO dto = new CompanyDTO();
        dto.setId(this.getId());
        dto.setCreateTime(DateUtil.format(this.getCreateTime()));
        dto.setUpdateTime(DateUtil.format(this.getUpdateTime()));
        dto.setCreator(this.getCreator());
        dto.setUpdater(this.getUpdater());
        dto.setName(this.getName());
        dto.setCode(this.getCode());
        dto.setState(this.getState());
        dto.setContacts(this.getContacts());
        dto.setMobile(this.getMobile());
        dto.setRemark(this.getRemark());
        dto.setType(this.getType());
        dto.setMaterialId(this.getMaterialId());
        dto.setProductId(this.getProductId());
        return dto;
    }
}
